<template>
	<view style="padding: 20rpx;">
		<view class="item" v-for="(item,index) in list" @click="details(item.id,index)">
			<view class="righttext">
				<view class="" style="display: flex;justify-content: space-between;margin-top: 15rpx;">
					<view class="" style="font-size: 32rpx;font-weight: bold;max-width: 70%;">
						{{item.title}}
					</view>
					<view class="">
						{{item.createtime}}
					</view>
				</view>
				<view class="content">
					{{item.brief}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { Admit } from '../../model/admitnotice-model.js';
	
	var Admits = new Admit();
	export default {
		data() {
			return {
				page: 1,
				list: []
			}
		},
		onLoad() {
			this.getdata()
		},
		onReachBottom() {
			console.log('触底')
			this.page++
			this.getdata()
		},
		methods: {
			details(id,index){
				if(this.list[index].to_link == ''){
					uni.navigateTo({
						url:'/pages/admitnotice/details?id='+id
					})
				}else{
					window.location.href = this.list[index].to_link
				}
			},
			getdata() {
				var that = this
				let params = {
					page: this.page
				}
				Admits.Lists((data) => {
					console.log(data)
					if (data.code === 1) {
						that.list = that.list.concat(data.data.data)
					} else {
						uni.showToast({
							title: data.msg,
							icon: 'none',
							duration: 2000
						})
					}
				}, params)
			}
		}
	}
</script>

<style>
	page {
		background-color: #f1f1f1;
	}

	.item {
		padding: 20rpx;
		border-radius: 10rpx;
		display: flex;
		background-color: #fff;
		margin-bottom: 20rpx;
	}

	

	.righttext {
		width:100%;
		display: flex;
		flex-direction: column;
		
	}

	.content {
		overflow: hidden; //超出的文本隐藏
		display: -webkit-box;
		-webkit-line-clamp: 2; // 超出多少行
		-webkit-box-orient: vertical;
		margin-top: 10rpx;
	}
</style>